/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package conexion;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
 *
 * @author Deico
 */
public class DB {
    
     public static  Connection DB_CONNECTION = getConnection();
     
     public static Connection getConnection(){
      
      String driver = "com.mysql.jdbc.Driver";
      String dbname = "sviews";
      String url = "jdbc:mysql://localhost/" +  dbname;
      String username = "root";
      String password = "12qw12qw";

        Connection conData = null;
       
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException ex) {
            System.out.println(ex);
        }
        try {
            conData = DriverManager.getConnection(url,username,password);
            return conData;
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Error en la base de datos: "+ ex, "Error: PostgreSQL", JOptionPane.ERROR_MESSAGE);
            return conData;
        }
        
     
  }
}
